//
//  FriendTableViewCell.m
//  Final
//
//  Created by lanou3g on 15/12/5.
//  Copyright © 2015年 皮比诺. All rights reserved.
//

#import "FriendTableViewCell.h"


@interface FriendTableViewCell()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)NSMutableArray *dataArray;
@end

@implementation FriendTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.dataArray = [NSMutableArray array];
        [self makedata];
        
    }
    
       return self;
    
}

-(void)makedata
{
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44);
    [self.contentView addSubview:self.button];
    
    [self.button addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    self.button.selected = NO;
    
    self.tableView = [[UITableView alloc]init];
    self.tableView.frame = CGRectMake(0, 44, [UIScreen mainScreen].bounds.size.width, 44*5);
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"textcell"];
    
    
    
}
- (void)buttonAction:(UIButton *)sender
{
    
    self.button.selected = !self.button.selected;
    if (self.button.selected == YES) {
        [self showTableView];
        
//        self.backgroundColor = [UIColor redColor];
    }else{
       
        [self hiddenTableView];
    }
    
    
    
    if (self.Delegate != nil && [self.Delegate respondsToSelector:@selector(roloadTableview)]) {
        
        [self.Delegate roloadTableview];
        
    }
    
    
    [self.tableView reloadData];
    
}



-(void)showTableView
{
    [self.contentView addSubview:self.tableView];
    
}

- (void)hiddenTableView
{
    [self.tableView removeFromSuperview];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
    
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"textcell" forIndexPath:indexPath];

    cell.textLabel.text = @"hhhh";
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.backgroundColor = [UIColor redColor];
    return cell;
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
  
    return 44;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSLog(@"哈哈哈哈哈哈哈哈哈哈哈");
    
    if (self.Delegate != nil && [self.Delegate respondsToSelector:@selector(popTochatViewController:)]) {
        
        [self.Delegate popTochatViewController:nil];
        
    }
    

    
    
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
